import {BasePage} from "../../../../ts/type";
import {replace} from "../../../../ts/util";

export let extraConfig = (page: BasePage) => {
    replace(page, {
        models: [
            {
                formInputs: [
                    {
                        onChange: (v: string) => {
                            if (v) {
                                page.models[0].formInputs[1].disabled = false
                                page.models[0].formInputs[2].disabled = false
                                page.models[0].formInputs[1].options = page.options.labelFieldCode
                                    .filter((o: any) => o.tableCode === v)
                                page.models[0].formInputs[2].options = page.options.labelFieldCode
                                    .filter((o: any) => o.tableCode === v)
                            } else {
                                page.models[0].model.labelFieldCode = null
                                page.models[0].model.valueFieldCode = null
                                page.models[0].formInputs[1].disabled = true
                                page.models[0].formInputs[2].disabled = true
                            }
                        }
                    }, {
                        disabled: true
                    }, {
                        disabled: true
                    }
                ]
            }
        ]
    })
}